﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage/List.Master" AutoEventWireup="true" CodeBehind="Bu_Interest_List.aspx.cs" Inherits="Honestysoft.Financing.WebUI.Module.OtherBu.Bu_Interest_List" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <link href="../../Styles/jquery.validate.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/jquery.validate.js" language="javascript" type="text/javascript"></script>
    <script src="../../Scripts/jquery.validate.message_cn.js" language="javascript" type="text/javascript"></script>
    <script type="text/javascript" language="javascript" src="../../Scripts/jquery.easyui.min.js"></script>
    <script type="text/javascript" language="javascript" src="../../Scripts/easyui-lang-zh_CN.js"></script>
    <link rel="stylesheet" type="text/css" href="../../Styles/easyui.css" />
	<link rel="stylesheet" type="text/css" href="../../Styles/icon.css" />
    <script language="javascript" type="text/javascript">
        var opts = null;
        function InitRules() {            
        }	    
        function showReport(){           
            ifrmInfo.location.href = '<%=System.Configuration.ConfigurationManager.AppSettings["ReportServerURL"] %>/R012&rc:parameters=false';
        }
        function saveBankRate(){
            var dataString="";
		    if ($('#tBankRate').datagrid('acceptChanges')) {
		        var rows = $('#tBankRate').datagrid('getRows');
		        for (var i = 0; i < rows.length; i++) {
		            if (rows[i].ActiveDate == "") {
		                alert('第' + (i + 1) + '行的日期不能为空！');
		                return false;
		            }
		            if (rows[i].Rate == "") {
		                alert('第' + (i + 1) + '行的利率不能为空！');
		                return false;
		            } 
                    if(dataString != ""){
                        dataString += ",";
                    }
                    dataString += rows[i].ActiveDate+"|"+rows[i].Rate;
		        }
                if (dataString != "") {
                    $.ajax({
                        type: 'POST',
                        url: "Json/SaveBankRate.ashx",
                        data: { "Data": dataString },
                        success: function (msg) {
                            if (unescape(msg) != "0") {
                                alert(unescape(msg));
                                return false;
                            }
                            else {
                                alert('保存成功！');
                                showReport();
                            }
                        }
                    });
            }
            }
            
            return true;
        }
        function saveIntDate() {
            var dataString="";
		    if ($('#tIntDate').datagrid('acceptChanges')) {
		        var rows = $('#tIntDate').datagrid('getRows');
		        for (var i = 0; i < rows.length; i++) {
		            if (rows[i].IntDate == "") {
		                alert('第' + (i + 1) + '行的利息计算日不能为空！');
		                return false;
		            }
                    if(dataString != ""){
                        dataString += ",";
                    }
                    dataString += rows[i].IntDate;
		        }
                if(dataString != ""){
                    $.ajax({
                        type: 'POST',
                        url: "Json/SaveIntDate.ashx",
                        data: { "Data": dataString },
                        success: function (msg) {
                            if (unescape(msg) != "0") {
                                alert(unescape(msg));
                                return false;
                            }
                            else {
                                alert('保存成功！');
                                showReport();
                            }
                        }
                    });
            }
            }
            
            return true;
		}
		$(function () {
		    var lastIndex;
		    $('#tBankRate').datagrid({
		        loadMsg: "正在加载利率设置数据，请稍候……",
		        url: 'Json/GetBankRate.ashx?randID=' + escape(new Date()),
		        toolbar: [{
		            text: '新增',
		            iconCls: 'icon-add',
		            handler: function () {
		                $('#tBankRate').datagrid('endEdit', lastIndex);
		                $('#tBankRate').datagrid('appendRow', {
		                    ActiveDate: '',
		                    Rate: ''
		                });
		                var lastIndex = $('#tBankRate').datagrid('getRows').length - 1;
		                $('#tBankRate').datagrid('selectRow', lastIndex);
		                $('#tBankRate').datagrid('beginEdit', lastIndex);
		            }
		        }, '-', {
		            text: '删除',
		            iconCls: 'icon-remove',
		            handler: function () {
		                $('#tBankRate').datagrid('endEdit', lastIndex);
		                var row = $('#tBankRate').datagrid('getSelected');
		                if (row) {
		                    var index = $('#tBankRate').datagrid('getRowIndex', row);
		                    $('#tBankRate').datagrid('deleteRow', index);
		                }
		            }
		        }, '-', {
		            text: '保存',
		            iconCls: 'icon-save',
		            handler: function () {
		                saveBankRate();
		            }
		        }],
		        onBeforeLoad: function () {
		            $(this).datagrid('rejectChanges');
		        },
		        onClickRow: function (rowIndex) {
		            if (lastIndex != rowIndex) {
		                $('#tBankRate').datagrid('endEdit', lastIndex);
		                $('#tBankRate').datagrid('beginEdit', rowIndex);
		            }
		            lastIndex = rowIndex;
		        }
		    });



		    var lastIndex2;
		    $('#tIntDate').datagrid({
		        loadMsg: "正在加载计息日设置数据，请稍候……",
		        url: 'Json/GetIntDate.ashx?randID=' + escape(new Date()),
		        toolbar: [{
		            text: '新增',
		            iconCls: 'icon-add',
		            handler: function () {
		                $('#tIntDate').datagrid('endEdit', lastIndex2);
		                $('#tIntDate').datagrid('appendRow', {
		                    IntDate: ''
		                });
		                var lastIndex2 = $('#tIntDate').datagrid('getRows').length - 1;
		                $('#tIntDate').datagrid('selectRow', lastIndex2);
		                $('#tIntDate').datagrid('beginEdit', lastIndex2);
		            }
		        }, '-', {
		            text: '删除',
		            iconCls: 'icon-remove',
		            handler: function () {
		                $('#tIntDate').datagrid('endEdit', lastIndex2);
		                var row = $('#tIntDate').datagrid('getSelected');
		                if (row) {
		                    var index = $('#tIntDate').datagrid('getRowIndex', row);
		                    $('#tIntDate').datagrid('deleteRow', index);
		                }
		            }
		        }, '-', {
		            text: '保存',
		            iconCls: 'icon-save',
		            handler: function () {
		                saveIntDate();
		            }
		        }],
		        onBeforeLoad: function () {
		            $(this).datagrid('rejectChanges');
		        },
		        onClickRow: function (rowIndex) {
		            if (lastIndex2 != rowIndex) {
		                $('#tIntDate').datagrid('endEdit', lastIndex2);
		                $('#tIntDate').datagrid('beginEdit', rowIndex);
		            }
		            lastIndex2 = rowIndex;
		        }
		    });
		    showReport();
		});		
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <table cellpadding="0" cellspacing="0" border="0" width="100%">
        <tr>
            <td width="200px" style="vertical-align:top">
                
                <table id="tBankRate" style="width:200px;height:auto;" title="银行利率设置" 
			        singleSelect="true">
		            <thead>
			            <tr>
				            <th field="ActiveDate" width="120" editor="{type:'datebox'}">日期</th>
				            <th field="Rate" width="70" align="right" editor="{type:'numberbox',options:{precision:4}}">利率</th>
			            </tr>
		            </thead>
	            </table>
                <br />
                 <table id="tIntDate" style="width:200px;height:auto;" title="计息日设置" 
			        singleSelect="true">
		            <thead>
			            <tr>
				            <th field="IntDate" width="138" editor="{type:'datebox'}">利息计算日</th>
			            </tr>
		            </thead>
	            </table>
            </td>
            <td>

                 <iframe id="ifrmInfo" scrolling="yes" frameborder="0"  src="" style="width:100%;height:480px;"></iframe> 

            </td>
        </tr>
    </table>
    
</asp:Content>
